#include<vector>
using namespace std;

class Solution {
public:
    bool findTargetIn2DPlants(vector<vector<int>>& plants, int target) {
        vector<vector<int>> check;
        if (plants.size() == 0)return false;
        int m = plants.size(), n = plants[0].size();
        for (int i = 0; i < m; i++)
            for (int j = 0; j < n; j++) {
                if (plants[i][j] == target)
                    check.push_back({ i, j });
            }
        int cm = check.size();
        for (int i = 0; i < cm; i++) {
            int x = check[i][0], y = check[i][1];
            if (((x + 1 >= m || plants[x + 1][y] >= plants[x][y])) &&
                (y + 1 >= n || plants[x][y + 1] >= plants[x][y]))
                return true;
        }
        return false;
    }
};